/**
 * 应用路由常量定义
 * 统一管理所有路由路径，便于维护和类型检查
 */

export const ROUTES = {
  HOME: '/home',
  TEXT_DOCUMENT_LIST: '/text',
  TEXT_EDITOR: '/text/editor/:id?',
  STORYBOARD: '/storyboard',
  STORYBOARD_PROJECT: '/storyboard/project/:projectId',
  STORYBOARD_VIEW: '/storyboard/view/:projectId',
  DATA_COLLECTION: '/data-collection',
  DATA_ANALYTICS: '/data/analytics',
  DATA_HOTSPOT: '/data/hotspot'
} as const

export type RouteKey = keyof typeof ROUTES
export type RoutePath = typeof ROUTES[RouteKey]

/**
 * 路由配置接口
 */
export interface RouteConfig {
  path: string
  element: React.ComponentType
  key: string
  title: string
}

/**
 * 路由标题配置
 * 每个路由对应的页面标题
 */
export const ROUTE_TITLES = {
  [ROUTES.HOME]: '欢迎使用融媒智创工坊',
  [ROUTES.TEXT_DOCUMENT_LIST]: '文本稿件创建',
  [ROUTES.TEXT_EDITOR]: '智能写作编辑器',
  [ROUTES.STORYBOARD]: '分镜项目管理',
  [ROUTES.STORYBOARD_PROJECT]: '分镜项目编辑',
  [ROUTES.STORYBOARD_VIEW]: '分镜故事板',
  [ROUTES.DATA_COLLECTION]: '数据采集分析',
  [ROUTES.DATA_ANALYTICS]: '融媒数据分析',
  [ROUTES.DATA_HOTSPOT]: '热点分析'
} as const

/**
 * 菜单项与路由的映射关系
 */
export const MENU_ROUTE_MAP = {
  'home': ROUTES.HOME,
  'text': ROUTES.TEXT_DOCUMENT_LIST,
  'storyboard': ROUTES.STORYBOARD,
  'data': ROUTES.DATA_COLLECTION,
  'data-analytics': ROUTES.DATA_ANALYTICS,
  'data-hotspot': ROUTES.DATA_HOTSPOT
} as const

export type MenuKey = keyof typeof MENU_ROUTE_MAP

/**
 * 根据路由路径获取页面标题
 */
export const getRouteTitle = (path: string): string => {
  return ROUTE_TITLES[path as RoutePath] || '融媒智创工坊'
}
